﻿#region [ License information          ]
/* ************************************************************
 *
 * Copyright (c) Bjørn Bouet Smith, 2010, 2011
 *
 * This source code is subject to terms and conditions of 
 * Microsoft Public License (Ms-PL).
 * 
 * A copy of the license can be found in the license.txt
 * file at the root of this distribution. If you can not 
 * locate the License, please send an email to bjornsmith@gmail.com
 * 
 * By using this source code in any fashion, you are 
 * agreeing to be bound by the terms of the Microsoft 
 * Public License.
 *
 * You must not remove this notice, or any other, from this
 * software.
 *
 * ************************************************************/
#endregion

using System;
using System.Collections.Generic;
using System.Linq;

using System.Text;
using NUnit.Framework;

namespace Restful.Net.Tests
{
    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    [TestFixture]
    public class AcceptTests
    {
        [Test]
        public void ShouldParseSimpleCorrectly()
        {
            const string Header = "text/plain";

            Accept a = new Accept(Header);

            Assert.That(a.MediaType, Is.EqualTo(Header));
        }

        [Test]
        public void ShouldParseSimpleWithQualityCorrectly()
        {
            const string Header = "text/plain ; q=0.7";

            Accept a = new Accept(Header);

            Assert.That(a.MediaType, Is.EqualTo("text/plain"));
            Assert.That(a.Quality, Is.EqualTo(0.7f));
        }

        [Test]
        public void ShouldParseSimpleWithLevelCorrectly()
        {
            const string Header = "text/plain;level=1";

            Accept a = new Accept(Header);

            Assert.That(a.MediaType, Is.EqualTo("text/plain"));
            Assert.That(a.Quality, Is.EqualTo(1f));
        }

        [Test]
        public void ShouldParseBadHeaderCorrectly()
        {
            const string Header = "text/plain;";

            Accept a = new Accept(Header);

            Assert.That(a.MediaType, Is.EqualTo("text/plain"));
            Assert.That(a.Quality, Is.EqualTo(1f));
        }

    }
}
